const { Schema, model } = require('mongoose');
const { userModel } = require("./userModel")
const { ordersModel } = require("./ordersModel")
const { insurancesModel } = require("./insurancesModel")

const claimsSchema = new Schema({
  ordersCode: {
    type: Schema.Types.ObjectId,
    ref: ordersModel
  },
  voucher: {
    type: String,
    default: "尚未提交凭证"
  },
  userCode: {
    type: Schema.Types.ObjectId,
    ref: userModel
  },
  losses: String,
  reason: String,
  delete: {
    type: Boolean,
    default: false
  },
  insurancesCode: {
    type: Schema.Types.ObjectId,
    ref: insurancesModel
  },
  state: {
    type: String,
    default: 0
  },
  datenow: {
    type: Date,
    default: Date.now()
  }
}, { versionKey: false })

const claimsModel = model("claimsModel", claimsSchema, "claims")
module.exports.claimsModel = claimsModel